#!/bin/bash

# using script input arguments as process.
if [ -n "$1" ]
then
    process=$@
fi

for p in $process
do
    pidof $p >& /dev/null
    if [ $? -eq 0 ]
    then
        for id in $(pidof $p)
        do
            echo -17 > /proc/$id/oom_adj
        done
    else
        echo $p is invalid process name
    fi
done